(function() {
  'use strict';

  angular
    .module('hp')
    .controller('MachineCodeController', MachineCodeController);

  /** @ngInject */
  function MachineCodeController($log,toastr,$scope,$state,$stateParams,MachineCodeService,$rootScope) {
    var vm = this;
    vm.list = [];

    MachineCodeService.query({body:{}}).$promise.then(function(data){
        // $rootScope.$broadcast('loading:finished','');
        var c = data || {};
        var code = c.head.errorCode + '';
        switch (code) {
            case '200':
                vm.list = c.body?c.body.list?c.body.list:[]:[];
                break;
            case '401':
            case '403':
                // $state.go('login')
                $rootScope.$broadcast('event:auth-require',{});
                break;
            default:
                toastr.info('' + c.head.errorMsg)
        }
    },function(err){
        toastr.info('服务器正忙:'+err)
        // $rootScope.$broadcast('loading:finished','');
        $log.debug(err);
    });

  }


})();
